﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Security.Cryptography;
using Models;

namespace DAL
{
    public static class UserDAL
    {
        /// <summary>
        /// 登陆
        /// </summary>
        public static V_Users Login(string name, string pwd)
        {
            //进行MD5加密
            //pwd = BitConverter.ToString(MD5.Create().ComputeHash(Encoding.Default.GetBytes(pwd))).Replace("-", "");
            //准备参数
            SqlParameter[] pars = new SqlParameter[2];
            pars[0] = new SqlParameter("@name", name);
            pars[1] = new SqlParameter("@pwd", pwd);
            //执行查询
            string sql = "select * from V_Users where UserLName=@name and UserLPWD=@pwd";
            List<V_Users> list = BaseDAL.Select<V_Users>(sql, pars);
            //返回结果
            if (list.Count > 0)
                return list[0];
            else
                return null;

        }
    }
}
